package com.fitns.user.mapper.baseConfig;

import static com.fitns.user.mapper.baseConfig.TbWorkTimeDynamicSqlSupport.*;

import com.fitns.user.model.baseConfig.TbWorkTime;

import java.util.List;
import javax.annotation.Generated;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

@Mapper
public interface TbWorkTimeMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<TbWorkTime> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TbWorkTimeResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="organ_id", property="organId", jdbcType=JdbcType.BIGINT),
        @Result(column="begin_time", property="beginTime", jdbcType=JdbcType.TIME),
        @Result(column="end_time", property="endTime", jdbcType=JdbcType.TIME),
        @Result(column="descs", property="descs", jdbcType=JdbcType.VARCHAR),
        @Result(column="input_time", property="inputTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="create_id", property="createId", jdbcType=JdbcType.BIGINT),
        @Result(column="modify_id", property="modifyId", jdbcType=JdbcType.BIGINT)
    })
    List<TbWorkTime> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(tbWorkTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, tbWorkTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(TbWorkTime record) {
        return insert(SqlBuilder.insert(record)
                .into(tbWorkTime)
                .map(name).toProperty("name")
                .map(organId).toProperty("organId")
                .map(beginTime).toProperty("beginTime")
                .map(endTime).toProperty("endTime")
                .map(descs).toProperty("descs")
                .map(inputTime).toProperty("inputTime")
                .map(modifyTime).toProperty("modifyTime")
                .map(createId).toProperty("createId")
                .map(modifyId).toProperty("modifyId")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(TbWorkTime record) {
        return insert(SqlBuilder.insert(record)
                .into(tbWorkTime)
                .map(name).toPropertyWhenPresent("name", record::getName)
                .map(organId).toPropertyWhenPresent("organId", record::getOrganId)
                .map(beginTime).toPropertyWhenPresent("beginTime", record::getBeginTime)
                .map(endTime).toPropertyWhenPresent("endTime", record::getEndTime)
                .map(descs).toPropertyWhenPresent("descs", record::getDescs)
                .map(inputTime).toPropertyWhenPresent("inputTime", record::getInputTime)
                .map(modifyTime).toPropertyWhenPresent("modifyTime", record::getModifyTime)
                .map(createId).toPropertyWhenPresent("createId", record::getCreateId)
                .map(modifyId).toPropertyWhenPresent("modifyId", record::getModifyId)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbWorkTime>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, id, name, organId, beginTime, endTime, descs, inputTime, modifyTime, createId, modifyId)
                .from(tbWorkTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbWorkTime>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, id, name, organId, beginTime, endTime, descs, inputTime, modifyTime, createId, modifyId)
                .from(tbWorkTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(TbWorkTime record) {
        return UpdateDSL.updateWithMapper(this::update, tbWorkTime)
                .set(name).equalTo(record::getName)
                .set(organId).equalTo(record::getOrganId)
                .set(beginTime).equalTo(record::getBeginTime)
                .set(endTime).equalTo(record::getEndTime)
                .set(descs).equalTo(record::getDescs)
                .set(inputTime).equalTo(record::getInputTime)
                .set(modifyTime).equalTo(record::getModifyTime)
                .set(createId).equalTo(record::getCreateId)
                .set(modifyId).equalTo(record::getModifyId);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(TbWorkTime record) {
        return UpdateDSL.updateWithMapper(this::update, tbWorkTime)
                .set(name).equalToWhenPresent(record::getName)
                .set(organId).equalToWhenPresent(record::getOrganId)
                .set(beginTime).equalToWhenPresent(record::getBeginTime)
                .set(endTime).equalToWhenPresent(record::getEndTime)
                .set(descs).equalToWhenPresent(record::getDescs)
                .set(inputTime).equalToWhenPresent(record::getInputTime)
                .set(modifyTime).equalToWhenPresent(record::getModifyTime)
                .set(createId).equalToWhenPresent(record::getCreateId)
                .set(modifyId).equalToWhenPresent(record::getModifyId);
    }
}